package com.gg.fruit.controlller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.entity.Fruit;
import com.gg.fruit.service.FruitService;

import helpers.baseservlet.BaseServlet;

/**
 * Servlet implementation class SearchFruitsByPriceServlet
 */
@WebServlet("/fruit/SearchFruitsByPriceServlet")
public class SearchFruitsByPriceServlet extends BaseServlet {
	@Autowired
	private FruitService fruitService;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int min =Integer.parseInt(request.getParameter("min"));
		int max =Integer.parseInt(request.getParameter("max"));
		List<Fruit> fruits=fruitService.searchFruitsByPrice(min,max);
		request.getSession().setAttribute("searchfruits", fruits);
		response.sendRedirect("/fruits/sel.jsp");
	}


}
